package com.zyh.scs.admin.controller;

import com.zyh.scs.admin.api.entity.SysUser;
import com.zyh.scs.admin.service.SysUserService;
import com.zyh.scs.admin.utils.UUID;
import com.zyh.scs.common.core.util.R;
import com.zyh.scs.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author hwh
 * @ClassName: 测试controller$
 * @Description: $
 * @Date $
 * @Version 1.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/test")
@Tag(description = "test", name = "测试controller")
@Inner(value = false)
public class TestController {

    private final SysUserService sysUserService;


    @GetMapping("/test")
    @Operation(summary = "test", description = "test")
    public R<String> test() {
        return R.ok("成功");
    }


    @PostMapping("/copy")
    @Operation(summary = "copy", description = "copy")
    public R<Boolean> copy() {
        //copy
        SysUser sysUser = new SysUser();
        List<SysUser> sysUserList = new ArrayList<>();
        for (int i = 2; i < 10003; i++) {
            sysUser.setUsername(UUID.random6());
            sysUser.setUserId((long) i);
            Map<Integer, Integer> map = new HashMap<>();
            map.put(1, 1);

            Set<Integer> set = new HashSet<>();
            set.add(1);
            if (map.containsKey(1)) {
                System.out.println("包含");
            }
            sysUserList.add(sysUser);
        }

        sysUserService.saveBatch(sysUserList);
        return R.ok(true);
    }

}
